<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page isELIgnored="false" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html style="overflow-y: visible;">
    <jsp:include page="../../../include/IncludeMain.jsp"></jsp:include>
  <body style="overflow-y: visible!important;overflow-y: scroll;" onload="load()">
	  <form action="${pageContext.request.contextPath }/pages/business/CancelOut.do?act=save&cancelOut.id=${cancelOut.id }" name="myForm" id="myForm" method="post">
	    	<table class="mainTable">
				<thead>
					<tr class="tableController">
						<th colspan="2">
							<h3>冲单(出库)明细编辑</h3>
						</th>
					</tr>
					<tr>
						<th>&nbsp;	</th>
						<th class="errorTip" style='<c:if test="${empty message}">display:none</c:if>'>
							<c:forEach items="${message}" var="m">
								${m }
							</c:forEach>
						</th>
					</tr>
					<tr class="tableTitle">
						<th>
							<h3>&nbsp;</h3>
						</th>
						<th>
							<h3>&nbsp;</h3>
						</th>
					</tr>
				</thead>
				<tbody> 
					<tr>
						<td align="right"><h4>配码:&nbsp;&nbsp;</h4></td><!-- 以一个表格让用户输入八种尺寸鞋码 -->
						<td>
							<table>
								 <tr>
								  <th style="width:45px" align="center">鞋码</th>
								  <th align="center">33</th>
								  <th align="center">34</th>
								  <th align="center">35</th>
								  <th align="center">36</th>
								  <th align="center">37</th>
								  <th align="center">38</th>
								  <th align="center">39</th>
								  <th align="center">40</th>
								  <th align="center" style="width:40px">合计</th>
								 </tr>
								 <tr>
								  <th align="center">数量</th>
								  <input type="hidden" name="cancelOut.shoe_id" id="shoe_id" value="${shoe_id }"/>
								  <input type="hidden" name="cancelOut.order_shoe_id" id="order_shoe_id" value="${order_shoe_id }"/>
								  <th align="center"><input type="text" name="cancelOut.size_33" id="size_33" style="width:40px" validation="maxValue=${owned[0] }" value="${cancelOut.size_33 == null? 0:cancelOut.size_33}" onchange="calculate()"/></th>
								  <th align="center"><input type="text" name="cancelOut.size_34" id="size_34" style="width:40px" validation="maxValue=${owned[1] }" value="${cancelOut.size_34 == null? 0:cancelOut.size_34}" onchange="calculate()"/></th>
								  <th align="center"><input type="text" name="cancelOut.size_35" id="size_35" style="width:40px" validation="maxValue=${owned[2] }" value="${cancelOut.size_35 == null? 0:cancelOut.size_35}" onchange="calculate()"/></th>
								  <th align="center"><input type="text" name="cancelOut.size_36" id="size_36" style="width:40px" validation="maxValue=${owned[3] }" value="${cancelOut.size_36 == null? 0:cancelOut.size_36}" onchange="calculate()"/></th>
								  <th align="center"><input type="text" name="cancelOut.size_37" id="size_37" style="width:40px" validation="maxValue=${owned[4] }" value="${cancelOut.size_37 == null? 0:cancelOut.size_37}" onchange="calculate()"/></th>
								  <th align="center"><input type="text" name="cancelOut.size_38" id="size_38" style="width:40px" validation="maxValue=${owned[5] }" value="${cancelOut.size_38 == null? 0:cancelOut.size_38}" onchange="calculate()"/></th>
								  <th align="center"><input type="text" name="cancelOut.size_39" id="size_39" style="width:40px" validation="maxValue=${owned[6] }" value="${cancelOut.size_39 == null? 0:cancelOut.size_39}" onchange="calculate()"/></th>
								  <th align="center"><input type="text" name="cancelOut.size_40" id="size_40" style="width:40px" validation="maxValue=${owned[7] }" value="${cancelOut.size_40 == null? 0:cancelOut.size_40}" onchange="calculate()"/></th>
								  <th align="center" id="total" style="width:40px; color:#FF0000">0</th>
								 </tr>
								 <tr>
								  <th style="width:60px" align="center">仓库现有</th>
								  <th align="center">${owned[0] }</th>
								  <th align="center">${owned[1] }</th>
								  <th align="center">${owned[2] }</th>
								  <th align="center">${owned[3] }</th>
								  <th align="center">${owned[4] }</th>
								  <th align="center">${owned[5] }</th>
								  <th align="center">${owned[6] }</th>
								  <th align="center">${owned[7] }</th>
								  <th align="center" style="width:40px">${owned[0] + owned[1] + owned[2] + owned[3] + owned[4] + owned[5] + owned[6] + owned[7] }</th>
								 </tr>
								</table >
						</td>
					</tr> 
					<tr>
						<td align="right"><h4>日期:&nbsp;&nbsp;</h4></td>
						<td>
							<input type="text" validation="date,required" readonly="readonly" name="cancelOut.cancel_out_date" id="cancel_out_date" value="${cancelOut.cancel_out_date}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',lang:'zh-cn'})" class="Wdate" style="width:126px"/>
							<em style="color:red;">*</em>
						</td>
					</tr> 
					<tr>
						<td align="right"><h4>备注:&nbsp;&nbsp;</h4></td>
						<td><textarea cols="40" rows="5" name="cancelOut.comments" id="comments">${cancelOut.comments}</textarea></td>
					</tr> 
				</tbody>
				<tfoot>
					<tr  class="tableController_bottom">
						<td align="center">
							&nbsp;
						</td>
						<td align="left">
							<a class="button" href="javascript:void(0)" onclick="this.blur(); save();'return false';"><span><img src="${pageContext.request.contextPath }/js/kui/icons/disk.png" align="absmiddle"/>&nbsp;保存</span></a>
							<a class="button" href="javascript:void(0)" onclick="this.blur(); history.go(-1);'return false';"><span><img src="${pageContext.request.contextPath }/js/kui/icons/anticlockwise.png" align="absmiddle"/>&nbsp;返回</span></a>
						</td>
					</tr>
				</tfoot>
		</table>
		</form>
		<script type="text/javascript">
		
			var formId = 'myForm';
			var valid = new KUI.Validation({formId: formId, immediate: true});
			function save(){
				if(valid.validate()){
					document.getElementById(formId).submit();
				}
			}
			
			function calculate(){
				var num = 0;
				for(var i = 33; i <= 40; i++){
					if("" == document.getElementById("size_" + i).value){
						document.getElementById("size_" + i).value = 0;
					}
					num += parseInt(document.getElementById("size_" + i).value);
				}
				document.getElementById("total").innerHTML = num;
			}
		</script>
  </body>
</html>
